[#ftl]
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>[#assign module="resources"][#assign moduleName="资源"]
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="${base}/commonjs/flexgrid/css/flexigrid.pack.css" />

<script type="text/javascript" src="${base}/commonjs/jquery1.7.2/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="${base}/commonjs/flexgrid/js/flexigrid.js"></script>
<script type="text/javascript" src="${base}/commonjs/flexgrid/js/myflexigrid.js"></script>
<script type="text/javascript" src="${base}/commonjs/artDialog4/artDialog.source.js?skin=blue"></script>
<script type="text/javascript" src="${base}/commonjs/artDialog4/plugins/iframeTools.source.js"></script>
<title>${moduleName}列表</title>
</head>
<body>
<table class="flexme3" style="display: none"></table>
<script type="text/javascript">
var grid = $(".flexme3").flexigrid(generateFlexGridCfg({
	title:'${moduleName}列表',
	url : '${base}/${module}/list',
	dataType : 'json',
	singleSelect: true,
	colModel:[
	  		["ID", "id", 40, true, "asc",  "left", null],
			["Name", "name", 80, true, "",  "left", null],
			["ResourceId", "resourceid", 80, true, "",  "left", null],
			["Description", "description", 150, false, "",  "left", null],
			["Operation", "description", 120, false, "",  "left", function(data, id, rowData){
				return ['<a href="javascript:addItem('+id+')">编辑</a>',
				'<a href="javascript:removeItem('+id+')">删除</a>'
				].join(" ");
			}]
	],
	buttons: [
	  		["添加${moduleName}", "add", addItem],
			//["--"],
			//["删除${moduleName}", "delete", function(){alert(3)}]
	]
}));

function showFunctions(id){
    var url = '${base}/module/'+id+"/functions";
    art.dialog.open(url, {
        title: '属性列表',
        background: '#EEE', // 背景色
        opacity: 0.05,  // 透明度
        width: 850,
        height: 550
    }, true).lock();
}

function $1(id){
	return 	$("#"+id).val()
}
function flexGridReload(selector){
	$(selector).flexReload();
}
function addItem(id){
	var url = '${base}/${module}/add';
	if(id){
		url = '${base}/${module}/edit?id='+id;
	}
	var mode = id?"编辑":"添加新";
	art.dialog.open(url, {
		title: mode+'${moduleName}',
		background: '#EEE', // 背景色
		opacity: 0.05,	// 透明度
		width: 400,
		height: 300
	}).lock();
}
function removeItem(id){
	art.dialog({
		content: "确定要删除该${moduleName}【id="+id+"】？",
		title: "确认删除",
		icon: "question",
		background: '#EEE', // 背景色
		opacity: 0.05,	// 透明度
		lock: true,
		button: [{
			name: "确定",
			callback: function(){
				$.post("${base}/${module}/remove", {id: id}, function(text){
					var result = text;
					if(result.success){
						flexGridReload(".flexme3");
					}else{
						art.dialog({
							title: "删除失败",
							icon: "error",
							content: result.err,
							width: 400,
							height: 250,
							background: '#EEE', // 背景色
							opacity: 0.05,	// 透明度
							lock: true,
							ok: true
						});
					}
				});
			}
		}, {
			name: "取消",
			focus: true
		}]
	});
}

</script>

</body>
</html>